import UIKit

//extension DispatchQueue {
//    private static var _onceToken = [String]()
//    
//    class func once(token: String = "\(#file):\(#function):\(#line)", block: ()->Void) {
//        objc_sync_enter(self)
//        
//        defer
//        {
//            objc_sync_exit(self)
//        }
//
//        if _onceToken.contains(token)
//        {
//            return
//        }
//
//        _onceToken.append(token)
//        block()
//    }
//}

extension UIApplication {
    var dw_keyWindow: UIWindow? {
        self.connectedScenes
            .filter { $0.activationState == .foregroundActive }
            .compactMap { $0 as? UIWindowScene }.first?.windows
            .filter { $0.isKeyWindow }.first
    }
}

extension Array where Element: UIView {

    func dw_sortedArrayByTag() -> [Element] {
        return sorted(by: { (view1: Element, view2: Element) -> Bool in
            return (view1.tag < view2.tag)
        })
    }
    
    func dw_sortedArrayByPosition() -> [Element] {
        return sorted(by: { (view1: Element, view2: Element) -> Bool in
            if view1.frame.minY != view2.frame.minY {
                return view1.frame.minY < view2.frame.minY
            } else {
                return view1.frame.minX < view2.frame.minX
            }
        })
    }
}

struct DWKeyboardSignModel {
    
    weak var signView : UIView?
    
    var viewType : DWKeyboardViewType = .dw_vc
    
}
